/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * RectangleContr.java
 *
 * Created on 7.3.2010, 19:15:00
 */

/**
 *
 * @author Kuba
 */
public class RectangleContr extends javax.swing.JPanel {

    /** Creates new form RectangleContr */
    public RectangleContr() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        picture = new Picture();
        showBut = new javax.swing.JButton();
        wlSl = new javax.swing.JSlider();
        wlSp = new javax.swing.JSpinner();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        awSl = new javax.swing.JSlider();
        jLabel3 = new javax.swing.JLabel();
        awSp = new javax.swing.JSpinner();
        jLabel4 = new javax.swing.JLabel();
        ahSl = new javax.swing.JSlider();
        jLabel5 = new javax.swing.JLabel();
        ahSp = new javax.swing.JSpinner();
        jLabel6 = new javax.swing.JLabel();
        diSl = new javax.swing.JSlider();
        jLabel7 = new javax.swing.JLabel();
        diSp = new javax.swing.JSpinner();
        jLabel8 = new javax.swing.JLabel();
        inSl = new javax.swing.JSlider();
        jLabel9 = new javax.swing.JLabel();
        inSp = new javax.swing.JSpinner();
        jLabel10 = new javax.swing.JLabel();

        setPreferredSize(new java.awt.Dimension(840, 531));

        picture.setPreferredSize(new java.awt.Dimension(500, 500));

        javax.swing.GroupLayout pictureLayout = new javax.swing.GroupLayout(picture);
        picture.setLayout(pictureLayout);
        pictureLayout.setHorizontalGroup(
            pictureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 500, Short.MAX_VALUE)
        );
        pictureLayout.setVerticalGroup(
            pictureLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 500, Short.MAX_VALUE)
        );

        showBut.setText("Show");
        showBut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                showButActionPerformed(evt);
            }
        });

        wlSl.setMajorTickSpacing(20);
        wlSl.setMaximum(700);
        wlSl.setMinimum(380);
        wlSl.setValue(540);
        wlSl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                wlSlStateChanged(evt);
            }
        });

        wlSp.setValue(530);
        wlSp.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                wlSpStateChanged(evt);
            }
        });

        jLabel1.setText("Wavelength");

        jLabel2.setText("nm");

        awSl.setMaximum(50000);
        awSl.setMinimum(1);
        awSl.setValue(12000);
        awSl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                awSlStateChanged(evt);
            }
        });

        jLabel3.setText("Aperture width");

        awSp.setValue(12000);
        awSp.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                awSpStateChanged(evt);
            }
        });

        jLabel4.setText("nm");

        ahSl.setMaximum(50000);
        ahSl.setMinimum(1);
        ahSl.setValue(16000);
        ahSl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                ahSlStateChanged(evt);
            }
        });

        jLabel5.setText("Aperture height");

        ahSp.setValue(16000);
        ahSp.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                ahSpStateChanged(evt);
            }
        });

        jLabel6.setText("nm");

        diSl.setMaximum(5000);
        diSl.setMinimum(100);
        diSl.setMinorTickSpacing(50);
        diSl.setValue(400);
        diSl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                diSlStateChanged(evt);
            }
        });

        jLabel7.setText("Distance");

        diSp.setValue(400);
        diSp.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                diSpStateChanged(evt);
            }
        });

        jLabel8.setText("mm");

        inSl.setMaximum(300);
        inSl.setMinimum(1);
        inSl.setValue(100);
        inSl.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                inSlStateChanged(evt);
            }
        });

        jLabel9.setText("Intensity");

        inSp.setValue(100);
        inSp.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                inSpStateChanged(evt);
            }
        });

        jLabel10.setText("x");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(picture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(142, 142, 142)
                        .addComponent(showBut)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 72, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(jLabel5)
                            .addComponent(jLabel3)
                            .addComponent(jLabel9)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(awSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel1)
                                            .addComponent(wlSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(ahSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(inSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(inSp, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                                            .addComponent(awSp, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                                            .addComponent(ahSp, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)
                                            .addComponent(wlSp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 79, Short.MAX_VALUE)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(diSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(diSp)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel8))))
                        .addGap(44, 44, 44))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(picture, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(42, 42, 42)
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(wlSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel2)
                                .addComponent(wlSp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel9)
                        .addGap(1, 1, 1)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(inSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(6, 6, 6)
                                        .addComponent(jLabel10)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jLabel3))
                            .addComponent(inSp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(awSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(awSp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ahSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(ahSp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel6)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(diSl, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(diSp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(63, 63, 63)
                        .addComponent(showBut)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void showButActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showButActionPerformed
        // TODO add your handling code here:
        picture.setLambda(((Integer) wlSp.getValue()).intValue());  //nm -> nm
        picture.setExposition(((Integer) inSp.getValue()).intValue());
        picture.setApertureWidth(((Integer) awSp.getValue()).intValue());//nm -> nm
        picture.setApertureHeight(((Integer) ahSp.getValue()).intValue());//nm -> nm
        picture.setZ(((Integer) diSp.getValue()).intValue()*10e6); //mm -> nm


//        picture.setLambda(((Integer) wlSp.getValue()).intValue());
//        picture.setExposition(((Integer) inSp.getValue()).intValue());
//        picture.setApertureWidth(((Integer) awSp.getValue()).intValue());
//        picture.setApertureHeight(((Integer) ahSp.getValue()).intValue());
//        picture.setZ(((Integer) diSp.getValue()).intValue());

        picture.setType("rectangle");
        picture.repaint();
    }//GEN-LAST:event_showButActionPerformed

    private void wlSlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_wlSlStateChanged
        // TODO add your handling code here:
         wlSp.setValue(wlSl.getValue());
    }//GEN-LAST:event_wlSlStateChanged

    private void wlSpStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_wlSpStateChanged
        // TODO add your handling code here:
        wlSl.setValue((Integer) wlSp.getValue());
    }//GEN-LAST:event_wlSpStateChanged

    private void inSlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_inSlStateChanged
        // TODO add your handling code here:
          inSp.setValue(inSl.getValue());
    }//GEN-LAST:event_inSlStateChanged

    private void inSpStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_inSpStateChanged
        // TODO add your handling code here:
        inSl.setValue((Integer) inSp.getValue());
    }//GEN-LAST:event_inSpStateChanged

    private void awSlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_awSlStateChanged
        // TODO add your handling code here:
        awSp.setValue(awSl.getValue());
    }//GEN-LAST:event_awSlStateChanged

    private void awSpStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_awSpStateChanged
        // TODO add your handling code here:
        awSl.setValue((Integer) awSp.getValue());
    }//GEN-LAST:event_awSpStateChanged

    private void ahSlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_ahSlStateChanged
        // TODO add your handling code here:
        ahSp.setValue(ahSl.getValue());
    }//GEN-LAST:event_ahSlStateChanged

    private void ahSpStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_ahSpStateChanged
        // TODO add your handling code here:
        ahSl.setValue((Integer) ahSp.getValue());
    }//GEN-LAST:event_ahSpStateChanged

    private void diSlStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_diSlStateChanged
        // TODO add your handling code here:
        diSp.setValue(diSl.getValue());
    }//GEN-LAST:event_diSlStateChanged

    private void diSpStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_diSpStateChanged
        // TODO add your handling code here:
        diSl.setValue((Integer) diSp.getValue());
    }//GEN-LAST:event_diSpStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSlider ahSl;
    private javax.swing.JSpinner ahSp;
    private javax.swing.JSlider awSl;
    private javax.swing.JSpinner awSp;
    private javax.swing.JSlider diSl;
    private javax.swing.JSpinner diSp;
    private javax.swing.JSlider inSl;
    private javax.swing.JSpinner inSp;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private Picture picture;
    private javax.swing.JButton showBut;
    private javax.swing.JSlider wlSl;
    private javax.swing.JSpinner wlSp;
    // End of variables declaration//GEN-END:variables

}
